package com.ktgj.hotel.api.factory;

import com.ktgj.common.core.domain.R;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.hotel.api.RemoteHotelService;
import com.ktgj.hotel.api.domain.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

@Component
public class RemoteHotelFallbackFactory implements FallbackFactory<RemoteHotelService> {

    private static final Logger log = LoggerFactory.getLogger(RemoteHotelFallbackFactory.class);

    @Override
    public RemoteHotelService create(Throwable cause) {
        log.error("酒店服务调用失败:{}", cause.getMessage());
        return new RemoteHotelService() {

            @Override
            public List<DicProvinceVoApi> allDicProvince() {
                log.error("获取省信息失败", cause.getMessage());
                return null;
            }

            @Override
            public List<DicCityVoApi> allDicCityList() {
                log.error("获取市信息失败", cause.getMessage());
                return null;
            }

            @Override
            public List<DicCountyVoApi> allDicCountyList() {
                log.error("获取县信息失败", cause.getMessage());
                return null;
            }

            @Override
            public DicCountyVoApi countyId(String countyName) {
                log.error("获取县、区id信息失败", cause.getMessage());
                return null;
            }

            @Override
            public List<HotelOrderApi> hotelOrderNum(Map<String, Object> map) {
                log.error("获取酒店订单量失败", cause.getMessage());
                return null;
            }

            @Override
            public int queryHotelOrderNumber(Long customerId) {
                log.error("获取用户下有多少笔酒店订单失败", cause.getMessage());
                return 0;
            }

            @Override
            public String dicCityLngAnfLat(Map<String, Object> map) {
                log.error("获取经纬度失败", cause.getMessage());
                return null;
            }

            @Override
            public JourneyHotelVoApi journeyHotelVo(Map<String, Object> map) {
                log.error("获取行程酒店订单信息失败", cause.getMessage());
                return null;
            }

            @Override
            public DicCityApi selectCityName(Map<String, Object> map) {
                log.error("获取城市名称失败", cause.getMessage());
                return null;
            }

            @Override
            public Long selectCityId(Map<String, Object> map) {
                log.error("获取城市id失败", cause.getMessage());
                return null;
            }

            @Override
            public R<HotelOrder> getInfo(Long orderid) {
                return R.fail("获取酒店订单详情失败！" + cause.getMessage());
            }

            @Override
            public R<HotelOrderPaydetail> selectHotelOrderPaydetailByorderId(Long orderid) {
                return R.fail("查询支付明细失败！" + cause.getMessage());
            }

            @Override
            public AjaxResult edit(HotelOrder hotelOrder) {
                log.error("修改酒店订单失败！", cause.getMessage());
                return null;
            }

            @Override
            public AjaxResult updateOrderPaydetailByOrderId(HotelOrderPaydetail hotelOrderPaydetail) {
                log.error("修改支付明细失败！" + cause.getMessage());
                return null;
            }

            @Override
            public HotelOrder order(Map<String, Object> map) {
                log.error("获取酒店订单id失败！" + cause.getMessage());
                return null;
            }

            @Override
            public HotelOrderPaginationVo orderList(HotelParameterVo hotelParameterVo) {
                log.error("获取酒店订单数量失败！" + cause.getMessage());
                return null;
            }

            @Override
            public HotelOrder orderNum(Map<String, Object> map) {
                log.error("获取酒店信息失败！" + cause.getMessage());
                return null;
            }

            @Override
            public List<HotelOrder> orderListThings()
            {
                return null;
            }
        };
    }
}
